import { createRouter, createWebHistory } from 'vue-router'
import Layout from '../layout/Layout.vue'

const routes = [
  {
    path: '/',
    name: 'Layout',
    component: Layout,
    redirect:"/shopping",            //重定向
    children:[
      {
        path: 'user',
        name: 'User',
        component: () => import("@/views/User"),
      },
      {
        path: 'goods',
        name: 'Goods',
        component: () => import("@/views/Goods"),
      },
      {
        path: 'shopping',
        name: 'Shopping',
        component: () => import("@/views/Shopping"),
      },
      {
        path: 'cartgoods',
        name: 'Cartgoods',
        component: () => import("@/views/Cartgoods"),
      },
    ]
  },
  {
    path: '/login',
    name: 'Login',
    component:() => import("@/views/Login"),
  },
  {
    path: '/register',
    name: 'Register',
    component:() => import("@/views/Register"),
  },
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
